package com.fortest;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.apache.commons.fileupload.util.Streams;

import java.io.*;

public class Test7 {
    public static void main(String[] args){
        String path="E:\\毕设有关\\题库\\Excel图片\\";
        try{
            jxl.Workbook wb =null;
            InputStream is = new FileInputStream("E:\\毕设有关\\题库\\excel文件\\test2.xls");
            wb = Workbook.getWorkbook(is);

            int sheetSize = wb.getNumberOfSheets();
            Sheet sheet = wb.getSheet(0);
            int row_total = sheet.getRows();

            System.out.println();
            FileOutputStream writer=null;
            int k=0;
            int img_num=sheet.getNumberOfImages();
            for (int j = 0; j < row_total; j++) {

                    Cell[] cells = sheet.getRow(j);

                    for(int i=0;i<cells.length;i++){
                        System.out.print(cells[i].getContents());
                        System.out.print("  |");
                    }
                    System.out.println();
                    if((!"".equals(cells[1].getContents()))&&k<img_num) {
                    writer = new FileOutputStream(path + cells[1].getContents());
                    writer.write(sheet.getDrawing(k).getImageData());
                    k++;
                }



            }
            writer.close();


        }catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (BiffException e){
            e.printStackTrace();
        }
    }
}
